<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<?php
session_start();
include 'query_mysql.php';
$qm=new query_mysql();
$username=$_REQUEST['username'];
echo $username."|";
$conn=mysqli_connect('127.0.0.1','root','123456','tpp');
$sql_txt="delete from tpp_user_info where username='$username'";
echo $sql_txt."|";
$order_count=@$qm->query_sql("select count(*) from order_info where username='$username'",'count(*)');
echo $order_count."|";
$last_order_time=@$qm->query_sql_2("select max(order_time) from order_info where username='$username'","max(order_time)");
echo $last_order_time."|";
$current_time=time();
echo $current_time."|";
$delete_orders="";
if ($order_count==0||($current_time-$last_order_time>=31536000)){//365天之前的订单可以删除
    $delete_user=mysqli_query($conn,$sql_txt);
    header("Location:http://localhost/index.php");
}else{
    echo "删除失败，你最近365天内有订单";
}

?>
</body>
</html>
